package cn.nexd.app.guestsystem.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import cn.nexd.framework.util.Logger;

/**
 * Created by wangxu on 16/8/29.
 */
public class DatabaseHelper extends SQLiteOpenHelper {

    private static final String TAG = "DatabaseHelper";
    private static String DB_NAME = "GuestSystem.db";
    private static int currentVersion = 1;

    private static DatabaseHelper instance;

    public static DatabaseHelper getInstance(Context context) {
        if (instance == null) {
            instance = new DatabaseHelper(context);
        }
        return instance;
    }

    private DatabaseHelper(Context context) {
        super(context, DB_NAME, null, currentVersion);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        String sql_1 = "create table users (company varchar, position varchar, family_name varchar, name varchar, weight integer)";
        Logger.debug(TAG, sql_1);
        sqLiteDatabase.execSQL(sql_1);

        String sql_2 = "create table mac (mac varchar primary key)";
        Logger.debug(TAG, sql_2);
        sqLiteDatabase.execSQL(sql_2);

    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {

    }
}
